home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 October: Mac OS SDK / Dev.CD Oct 96 SDK / Dev.CD Oct 96 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / ODFDev / ODF / Found / FWCommon / Include / FWStdDef.h < prev    next >
Encoding:
Text File  |  1996-08-16  |  5.8 KB  |  256 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWStdDef.h
  4. //    Release Version:    $ ODF 1 $
  5. //
  6. //    Copyright:    (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #ifndef FWSTDDEF_H
  11. #define FWSTDDEF_H
  12.  
  13. #ifndef FWENVDEF_H
  14. #include "FWEnvDef.h"
  15. #endif
  16.  
  17. #ifndef FWERRORS_H
  18. #include "FWErrors.h"
  19. #endif
  20.  
  21. #if defined(FW_BUILD_MAC) & !defined(__TYPES__)
  22. #include <Types.h>
  23. #endif
  24.  
  25. #if defined(FW_BUILD_MAC) & !defined(__FRAGRSRC__)
  26. #include "FragRsrc.h"
  27. #endif
  28.  
  29. #if defined(FW_BUILD_MAC) & !defined(__LOWMEM__)
  30. #include <LowMem.h>
  31. #endif
  32.  
  33. #if defined FW_BUILD_MAC  && !defined __FILES__
  34. #include <Files.h>
  35. #endif
  36.  
  37. #ifdef FW_BUILD_WIN
  38. #include <windows.h>
  39. #endif
  40.  
  41. FW_EXTERN_C_BEGIN
  42.  
  43. /*========================================================================================
  44. /  Build system macro definitions
  45. /========================================================================================*/
  46.  
  47. /*----------------------------------------------------------------------------------------
  48. /
  49. /     The macro SL_API is used to define more effecient calling convention for the Windows
  50. /    version    of the ODF shared library (SL).  It should be used like this:
  51. /
  52. /    void*    SL_APL    FW_OhWellWhateverNevermind(long l, short s);
  53. /
  54. /----------------------------------------------------------------------------------------*/
  55.  
  56. #ifdef FW_BUILD_MAC
  57.     #define SL_API
  58. #endif
  59.  
  60. #ifdef FW_BUILD_WIN
  61.     #define    SL_API            __stdcall
  62. #endif
  63.  
  64. #ifndef SOMCHKEXCEPT
  65. #define SOMCHKEXCEPT You_forgot_to_include_FWODExce_has_the_first_header_in your__cpp
  66. #endif
  67.  
  68. /*========================================================================================
  69. // Define OpenDoc version number so we can use appropriate interface
  70. /========================================================================================*/
  71.  
  72. #ifndef FW_OPENDOC_VERSION
  73.  
  74. #define FW_OPENDOC_DR1    1
  75. #define FW_OPENDOC_DR2    2
  76. #define FW_OPENDOC_DR3    3
  77. #define FW_OPENDOC_DR4    4
  78. #define FW_OPENDOC_100    FW_OPENDOC_DR4
  79. #define FW_OPENDOC_101    5
  80.  
  81. #ifdef FW_BUILD_MAC
  82. #define FW_OPENDOC_VERSION     FW_OPENDOC_DR4
  83. #endif
  84.  
  85. #ifdef FW_BUILD_WIN
  86. #define FW_OPENDOC_VERSION     FW_OPENDOC_DR2
  87. #endif
  88.  
  89. #endif
  90.  
  91. /*========================================================================================
  92. /  Type definitions
  93. /========================================================================================*/
  94.  
  95. #ifndef FW_COMPILER_SUPPORTS_BOOL
  96. //typedef unsigned char bool;
  97. #define false 0
  98. #define true 1
  99. #endif
  100.  
  101. typedef     unsigned char    FW_Boolean;
  102.  
  103. typedef     unsigned short     FW_ResourceId;
  104.  
  105. typedef     unsigned short     FW_Milliseconds;
  106.  
  107. typedef     unsigned long     FW_TypeToken;
  108.  
  109. // FW_Message is defined in "FWNotDef.h" which may be included by resource files
  110. // typedef     long            FW_Message; 
  111.  
  112. // ----- Macintosh -----
  113. #ifdef FW_BUILD_MAC
  114.  
  115. typedef     char**             FW_PlatformHandle;
  116.  
  117. typedef     unsigned long     FW_ResourceType;
  118.  
  119. struct FW_SCodeFragRefFile
  120. {
  121.     CFragResFileRef    fFragRef;            // Reference to resource map
  122.     short            fRefNum;            // RefNum of resource file
  123.     long            fNesting;            // Nesting level (>0 means in use)
  124. };
  125.  
  126. typedef     FW_SCodeFragRefFile* FW_Instance;
  127.  
  128. typedef     double_t         FW_Double;
  129.  
  130. typedef     Rect            FW_SPlatformRect;
  131. typedef     Point            FW_SPlatformPoint;
  132. typedef        short            FW_PlatformCoordinate;
  133.  
  134. #endif
  135.  
  136.  
  137. // ----- Windows -----
  138. #ifdef FW_BUILD_WIN
  139.  
  140. typedef        HANDLE             FW_PlatformHandle;
  141.  
  142. typedef     unsigned short     FW_ResourceType;
  143.  
  144. typedef     HINSTANCE         FW_Instance;
  145.  
  146. typedef     double             FW_Double;
  147.  
  148. typedef     RECT            FW_SPlatformRect;
  149. typedef     POINT            FW_SPlatformPoint;
  150.  
  151. #ifdef FW_BUILD_WIN32
  152. typedef        long            FW_PlatformCoordinate;
  153. #endif
  154. #ifdef FW_BUILD_WIN16
  155. typedef        int                FW_PlatformCoordinate;
  156. #endif
  157.  
  158. #endif
  159.  
  160. /*========================================================================================
  161. /  Mac A5 Globals
  162. /========================================================================================*/
  163.  
  164. #ifdef FW_BUILD_MAC
  165.  
  166. #pragma options align=mac68k
  167. typedef struct
  168. {
  169.     char        privates[76];
  170.     long        randSeed;
  171.     BitMap        screenBits;
  172.     Cursor        arrow;
  173.     Pattern        dkGray;
  174.     Pattern        ltGray;
  175.     Pattern        gray;
  176.     Pattern        black;
  177.     Pattern        white;
  178.     GrafPtr        thePort;
  179. } FW_QDGlobalRec;
  180.  
  181. #define FW_QDGlobals (*(FW_QDGlobalRec*)( *(char**)LMGetCurrentA5() \
  182.                             - sizeof(FW_QDGlobalRec) + sizeof(GrafPtr)))
  183.  
  184. #pragma options align=reset
  185. #endif
  186.  
  187. /*========================================================================================
  188. /  Constants
  189. /========================================================================================*/
  190.  
  191. #ifndef NULL
  192. #define NULL 0
  193. #endif
  194.  
  195. #ifndef FALSE
  196. #define FALSE 0
  197. #endif
  198.  
  199. #ifndef TRUE
  200. #define TRUE 1
  201. #endif
  202.  
  203. /*========================================================================================
  204. /  Macros
  205. /========================================================================================*/
  206.  
  207. #define FW_UNUSED(x)    ((void) &x)
  208.  
  209. FW_EXTERN_C_END
  210.  
  211. //========================================================================================
  212. //  Minimum and maximum functions
  213. //========================================================================================
  214.  
  215. #if 0
  216.  
  217. #define FW_PRIV_DEFINE_MIN_MAX(t)            \
  218.     inline t FW_Minimum(t a, t b)            \
  219.         {    return a < b ? a : b;    }        \
  220.     inline t FW_Maximum(t a, t b)            \
  221.         {    return a > b ? a : b;    }
  222.         
  223. #define FW_PRIV_DEFINE_ABS(t)                \
  224.     inline t FW_Absolute(t a)                \
  225.         {    return a < 0 ? -a : a; }
  226.  
  227. FW_PRIV_DEFINE_MIN_MAX(short)
  228. FW_PRIV_DEFINE_ABS(short)
  229.  
  230. FW_PRIV_DEFINE_MIN_MAX(unsigned short)
  231.  
  232. FW_PRIV_DEFINE_MIN_MAX(int)
  233. FW_PRIV_DEFINE_ABS(int)
  234.  
  235. FW_PRIV_DEFINE_MIN_MAX(unsigned int)
  236.  
  237. FW_PRIV_DEFINE_MIN_MAX(long)
  238. FW_PRIV_DEFINE_ABS(long)
  239.  
  240. FW_PRIV_DEFINE_MIN_MAX(unsigned long)
  241.  
  242. #else
  243.  
  244. template <class t>
  245. inline t FW_Minimum(t a, t b) { return a < b ? a : b; }
  246.  
  247. template <class t>
  248. inline t FW_Maximum(t a, t b) { return a > b ? a : b; }
  249.  
  250. template <class t>
  251. inline t FW_Absolute(t a) { return a < 0 ? -a : a; }
  252.  
  253. #endif
  254.  
  255. #endif
  256.